<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page language="java" contentType="text/html; UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>通知信息</title>
    <%
        String basePath = request.getScheme()
                + "://" + request.getServerName()
                + ":" + request.getServerPort()
                + request.getContextPath()
                + "/";
    %>
    <base href="<%=basePath%>">

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">

    <!-- Toastr style -->
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">

    <!-- Gritter -->
    <link href="js/plugins/gritter/jquery.gritter.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">


</head>

<body>
<div id="wrapper">
    <!-- 功能菜单 开始 -->
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav metismenu" id="side-menu">
                <li class="nav-header">

                    <jsp:include page="common.jsp"></jsp:include>
                </li>
                <li>
                    <a href="index.jsp"><i class="fa fa-diamond"></i> <span
                            class="nav-label">首页</span></a>
                </li>

                <li>
                    <a href="userController?action=index"><i class="fa fa-diamond"></i> <span class="nav-label">用户管理</span></a>
                </li>
                <li>
                    <a href="fieldController?action=index"><i class="fa fa-diamond"></i> <span class="nav-label">场地管理</span></a>
                </li>
                <li>
                    <a href="orderController?action=index"><i class="fa fa-diamond"></i> <span class="nav-label">预约记录</span></a>
                </li>
                <li class="active">
                    <a href="noticeController?action=index"><i class="fa fa-diamond"></i> <span class="nav-label">通知信息</span></a>
                </li>

            </ul>

        </div>
    </nav>
    <!-- 功能菜单 结束 -->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <ul class="nav navbar-top-links navbar-right">
                    <li>
                        <a href="userController?action=logout">
                            <i class="fa fa-sign-out"></i> 退出登录
                        </a>
                    </li>
                </ul>
            </nav>
        </div>

        <!-- 主显示区 -->
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <button class="btn btn-primary " id="add-btn" type="button" style="margin-top: 5px;"
                                data-toggle="modal" data-target="#myModal">
                            添加消息
                        </button>
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>消息id</th>
                                <th>主体内容</th>
                                <th width="150">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${requestScope.notices}" var="n">
                                <tr>
                                    <td>${n.nid}</td>
                                    <td>${n.context}</td>
                                    <td>
                                        <a href="noticeController?action=delete&nid=${n.nid}" class="btn btn-danger  dim "
                                           type="button"><i class="fa fa-trash"></i>
                                        </a>
                                        <a nid="${n.nid}" class="btn btn-info  dim updateModel" type="button"
                                           data-toggle="modal" data-target="#myModal2">
                                            <i class="fa fa-edit"></i>
                                        </a>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- 主显示区 -->

    </div>
</div>


<!-- 模态窗口 开始 -->
<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <!-- 模态窗口标题 -->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">添加消息</h4>
            </div>
            <!-- 模态窗口身体 -->
            <div class="modal-body">
                <form id="fm" role="form" method="post" action="noticeController" class="form-horizontal">
                    <input type="hidden" name="action" value="add">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">消息内容</label>
                        <div class="col-lg-10">
                            <textarea name="context" cols="30" rows="10" class="form-control"></textarea>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <!-- 模态窗口尾部 -->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary" id="save-btn">添加</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
<!-- 模态窗口 结束 -->

<!-- 模态窗口 开始 -->
<div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <!-- 模态窗口标题 -->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">修改消息</h4>
            </div>
            <!-- 模态窗口身体 -->
            <div class="modal-body">
                <form id="fm2" role="form" method="post" action="noticeController" class="form-horizontal">
                    <input type="hidden" name="nid" id="nid" value="${qnotice.nid}">
                    <input type="hidden" name="action" value="update">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">用户名</label>
                        <div class="col-lg-10">
                            <textarea class="form-control" name="context" cols="30" rows="10">${qnotice.context}</textarea>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <!-- 模态窗口尾部 -->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary" id="save-btn2">修改</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
<!-- 模态窗口 结束 -->

<!-- Mainly scripts -->
<script src="js/jquery-3.1.1.min.js"></script>
<script>
    $(function () {
        let $updateModel = $('.updateModel');
        $updateModel.click(function () {
            let nid = $(this).attr('nid');

            $.ajax({
                url: '/sport-javaweb/noticeController',
                data: {
                    "action": "query",
                    "nid": nid
                },
                type: "POST",
                dataType: 'html',
                success(data) {
                    $('body').html(data)

                    $('#myModal2').modal('show')
                }
            })

        })
    })

</script>

<script src="js/bootstrap.min.js"></script>
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<!-- Flot -->
<script src="js/plugins/flot/jquery.flot.js"></script>
<script src="js/plugins/flot/jquery.flot.tooltip.min.js"></script>
<script src="js/plugins/flot/jquery.flot.spline.js"></script>
<script src="js/plugins/flot/jquery.flot.resize.js"></script>
<script src="js/plugins/flot/jquery.flot.pie.js"></script>

<!-- Peity -->
<script src="js/plugins/peity/jquery.peity.min.js"></script>
<script src="js/demo/peity-demo.js"></script>

<!-- Custom and plugin javascript -->
<script src="js/inspinia.js"></script>
<script src="js/plugins/pace/pace.min.js"></script>

<!-- jQuery UI -->
<script src="js/plugins/jquery-ui/jquery-ui.min.js"></script>

<!-- GITTER -->
<script src="js/plugins/gritter/jquery.gritter.min.js"></script>

<!-- Sparkline -->
<script src="js/plugins/sparkline/jquery.sparkline.min.js"></script>

<!-- Sparkline demo data  -->
<script src="js/demo/sparkline-demo.js"></script>

<!-- ChartJS-->
<script src="js/plugins/chartJs/Chart.min.js"></script>

<!-- Toastr -->
<script src="js/plugins/toastr/toastr.min.js"></script>


</body>

</html>
